package com.shareyi.study.springboot.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * 页面功能
 *
 * @author zhangshibin
 * @since 2018/3/28
 */
@Controller
@RequestMapping("/")
public class PageTestController {

    @RequestMapping("/page/hello")
    public ModelAndView hello(){
        return new ModelAndView("thymeleaf/hello",
                "message", "Hello world");
    }

    @RequestMapping(value = "/error",produces = "text/plain;charset=UTF-8")
    @ResponseBody
    public String error(ModelMap context){
        return "templates/error.html";
    }



    @RequestMapping("/page/helloGroovy")
    public String helloGroovy(ModelMap context){
        context.put("hello","Hello world");
        return "tpl/hello";
    }

    @RequestMapping("/page/freemarker")
    public ModelAndView freemarker(){
        return new ModelAndView("ftl/freemarker",
                "message", "Hello world");
    }
}
